package com.czxy.dao;

import com.czxy.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 品牌 Mapper
 * @author Liuyunqin 17674029449@163.com
 * @date 2018/12/20 16:07
 */
@org.apache.ibatis.annotations.Mapper
public interface BrandMapper extends Mapper<Brand> {

    /**
     *
     * @param catId
     * @return
     */
    @Select("SELECT * FROM tb_brand WHERE id IN (SELECT brand_id FROM tb_category_brand WHERE category_id=#{catId})")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "brand_name",column = "brand_name"),
            @Result(property = "logo",column = "logo")
    })
    public List<Brand> findBrandByCatId(@Param("catId") Integer catId);
}
